{% extends "projects/base.html" %}

{% load i18n %}
{% load humanize %}
{% load pagination_tags %}
{% load project_tags %}
{% load things_tags %}

{% block head_title %}{% blocktrans %}Projects{% endblocktrans %}{% endblock %}

{% block body %}
    
    <h1>{% trans "Projects" %}</h1>
    
    <p>A <b>project</b> is a place to manage a group of people working on a common set of tasks. It is similar to a tribe in providing a wiki and threaded discussion but is invitation only and adds issue tracking.</p>
    
    {% if user.is_authenticated %}
        <div class="form-toggle">
            <p><span id="start-project-toggle">{% trans "Start your own project" %}</span></p>
            
            <form id="start-project" method="POST" action="{% url project_create %}">
                {% get_project_form as project_form %}
                <table>
                    {{ project_form }}
                    <tr><td></td><td><input type="hidden" name="action" value="create" /><input type="submit" value="{% trans 'create' %}"/></td></tr>
                </table>
            </form>
        </div>
    {% else %}
        {% url acct_signup as signup_url %}
        {% url acct_login as login_url %}
        <p>{% blocktrans %}<a href="{{ signup_url }}">Sign up</a> and <a href="{{ login_url }}">log in </a> to create your own project or join an existing one.{% endblocktrans %}</p>
    {% endif %}
    
    {% if objects %}
        {% display_search %}
        {% display_ordering %}
        {% autopaginate objects %}
        
        <dl>
            {% for project in objects %}
                {% show_project project %}
            {% endfor %}
        </dl>
        
        {% paginate %}
    {% else %}
        <p>No projects have been created yet.</p>
    {% endif %}
    
{% endblock %}

{% block extra_body %}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#start-project').hide();
            $('#start-project-toggle').click(function() {
                $('#start-project').slideToggle();
                $('#start-project').autoscroll();
                return false;
            });
            if ($('#start-project ul.errorlist').length) {
                $('#start-project').show();
                $('#start-project ul.errorlist').autoscroll();
            }
        });
    </script>
{% endblock %}

